{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww16960\viewh18540\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0 First we need a singleton:\
\
class OGLApp\
\{\
private: \
static OGLApp *oglapp  //Singleton pointer\
static void SetApplication(OGLApp *theapp)  //Set singleton pointer\
\
public:\
OGLApp() //Constructor\
~OGLApp() //Destructor\
bool OnInit() //Initialize all subsystems\
void OnEvent() //React to events\
void OnUpdate() //Update game logic\
void OnRender() //Render changes to the screen\
void OnExit() //Exit the game\
\}\
\
class OGLEventListener\
\{\
private: \
bool <vector> eventList; //stores list of possible game events\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 void writeEventData(params); //setter (needs to be private to prevent writes to it)\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 public:\
OGLEventListener(); //Constructor\
~OGLEventListener(); //Destructor\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 bool <vector> readEventData(); //getter\
string receiveEvents(params); //Receives messages from other cores. this may change from string to a custom ID data type\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 \}\
\
class OGLUpdate\
\{\
private:\
gameEntity <vector> gameObjectList; //a list storing all game objects of type "gameEntity"\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 void writeGameEntityData(params); //setter (needs to be private to prevent writes to it)\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 public:\
OGLUpdate(); //Constructor\
~OGLUpdate(); //Destructor\
gameEntity<vector> readGameEntityData(); //getter\
void updateGameEntity(params); //Reads through the Event list and updates the list of game entities\
\}\
\
class OGLRender\
\{\
private:\
\
public:\
OGLRender(); //Constructor\
~OGLRender(); //Destructor\
updateScreen(); //Calls swap buffers function to update screen\
\}\
\
class BaseEntity //This class is meant to be overridden!\
\{\
private:\
\
//All derived objects must contain the following to work correctly!\
string ID; //Base entities ID for message handling\
double positionX; //Objects X position\
double positionY; //Objects Y position\
double positionZ; //Objects Z position, for our demo it will be 0 since the z axis will be locked\
\
public:\
BaseEntity(); //Constructor\
~BaseEntity(); //Destructor\
void getID(const &object); //Getter for ID\
void setID(&object); //Setter for ID\
\}\
\
class OGLSceneManager\
\{\
private:\
sceneObject<vector> sceneStates; //Scene objects are a custom data type to store the scene and everything in it.\
\
public:\
OGLSceneManager(); //Constructor\
~OGLSceneManager(); //Destructor\
sceneObject<vector> getScene(); //Getter to view the sceneObject vector\
void setScene(params); //Set the current scene to the scene listed in params\
void addScene(params); //Setter to add more scenes to the sceneObject vector\
void removeScene(params); //Removes the specified scene from the sceneObject vector\
\}\
\
\
\
1. The UI core listens for keypresses. When someone presses "Left" for instance,\
the UI Core sends a message that says "Left was pressed!"\
\
2. The Event() listens for events and receives the message "Left was pressed".\
\
3. The Event() sets the "Left was pressed" bool to TRUE.\
\
4. The Update() on its next pass sees that "Left was pressed" == TRUE so\
it does the corresponding action (which is most likely to move the ship left) so it would\
do something like:\
\
playerShip.x = -5.0;\
\
5. During the render functions pass, it sees that "Oh the ships positioned changed" (It doesn't need a message\
it reads the ships position from the .x variable) and then draws it on the screen in that location.\
\
\
This loop repeats over and over while the game is running.\
\
Core Requirements\
\
Main game loop:\
\
1. Create singleton object to store application manager\
2. Initialize OpenGL, GLUT, and all subsystems (Physics, UI, Scripting, Graphics).\
3. Create event manager to listen for events and flag variables when events happen.\
4. Create update manager to read data from event manager and update objects and game states appropriately.\
5. Create render manager to control rendering of the frame.\
6. Exit game when user quits. \
\
Extras that need created:\
\
1. Game entity class. This class is what all game entities need to derive from and allows the message passing system to work.\
(Page 53 of programming game AI by example if anyone is interested at looking at what I mean). \
2. Game state class. This class switches between game states (title screen, game screen, game over screen, etc).\
\
\
Basically it works like this: \
\
1. OGLApp creates a new instance of the app.\
2. The scene manager can be called to create a "scene" like a title screen, level, etc. Objects are placed into the scene. The objects (like a player ship, background, etc) are derived from the BaseEntity class.)\
3. While the scene is running, the event listener listens for events and sends messages to the updater function.\
4. The updater function reads the messages, updates all of the scene objects positions accordingly.\
5. The render function swaps the buffer to render those changes to the screen.}